import plotly.graph_objects as go
import plotly.express as px
# line plot
fig = go.Figure(data=go.Scatter(x=X,
y=Y,
mode='lines',
line=dict(color='#174A7E', width=5),
name='Processed'))
fig.add_trace(
go.Scatter(x=X,
y=Z,
mode='lines',
line=dict(color=GRAY4, width=5),
name='Received'))
# scatter plot
fig.add_trace(
go.Scatter(x=X[-5:],
y=Z[-5:],
mode='markers+text',
marker=dict(color=GRAY6, size=15),
text=[202, 160, 139, 149, 177],
textposition='top center',
name='Received'))
fig.add_trace(
go.Scatter(x=X[-5:],
y=Y[-5:],
mode='markers+text',
marker=dict(color=BLUE1, size=15),
text=Y[-5:],
textposition='bottom center',
name='Processed'))
# vertical line
fig.add_vline(x=4, line_width=2.5, line_color=GRAY1)
# xaxes
fig.update_xaxes(ticks="",
title_text='2014',
title_font=dict(size=18),
title_standoff=6,
tickfont=dict(size=18, family='Arial'),
range=(0, 12),
automargin=True)
# yaxes
fig.update_yaxes(range=(0, 300),
title_text='Number of tickets',
title_standoff=15,
title_font=dict(size=18, family='Arial'),
tickfont=dict(size=18, family='Arial'),
automargin=True)
# annotation
annotation = []
annotation.append(
dict(
xref='paper',
yref='paper',
x=-0.1,
y=-0.27,
xanchor='left',
yanchor='bottom',
text='Data source: XYZ Dashboard, as of 12/31/2014 | A detailed analysis'
' on tickets processed per person'
'and time <br> to resolve issues was undertaken to inform this request'
'and can be provided if needed.',
font=dict(family='Arial', size=11.5, color=GRAY3),
showarrow=False,
align='left'))
annotation.append(
dict(x=8.5,
y=280,
text='<b>2 employees quit in May</b>. We nearly kept up with'
' incoming <br>'
'volume in the following two months, but fell behind with the <br>'
'increase in Aug and haven'
't been able to catch up since.',
font=dict(family='Arial', size=16, color=GRAY5),
align='left',
showarrow=False))
annotation.append(
dict(x=-0.1,
y=1.45,
xref='paper',
yref='paper',
text='<b>Please approve the hire of 2 FTEs</b>',
font=dict(size=30, color=GRAY3),
showarrow=False))
annotation.append(
dict(x=-0.1,
y=1.32,
xref='paper',
yref='paper',
text='to backfill those who quit in the past year',
font=dict(size=20, color=GRAY7),
showarrow=False))
annotation.append(
dict(x=-0.1,
y=1.17,
xref='paper',
yref='paper',
text='Ticket volumn over time',
font=dict(family='Arial', size=22, color=GRAY2),
showarrow=False))
# label lines directly
annotation.append(
dict(xref='paper',
yref='paper',
x=1.1,
y=0.6,
text='Received',
font=dict(family='Arial', size=21, color=GRAY6),
showarrow=False))
annotation.append(
dict(xref='paper',
yref='paper',
x=1.12,
y=0.48,
text='Processed',
font=dict(family='Arial', size=21, color=BLUE1),
showarrow=False))
fig.update_layout(template='simple_white',
font=dict(family='Arial', size=22, color=GRAY4),
showlegend=False,
margin=dict(t=150, r=100),
height= 530,
width=800,
annotations=annotation)
fig.show()
fig.write_html("line+scatter.html")